
class BootStrapForm(object):
    bootstrap_class_exclude = []
    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)
        for name,field in self.fields.items(): # name是数据库中字段的名字，field是对象：<django.forms.fields.CharField object at 0x72129077b830>
            if name in self.bootstrap_class_exclude:
                continue
            if field.widget: # 通过field对象来判断，标签对象是否存在插件，存在的话把原class属性附加上。不存在插件的话就直接赋值
                old_class = field.widget.attrs.get('class', '')
                field.widget.attrs['class'] = '{} form-control'.format(old_class)
                field.widget.attrs['placeholder'] = field.label
            else:
                field.widget.attrs={'class': 'form-control', 'placeholder': field.label} # field.label是获取当前字段的label



















